package com.webapp.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

import java.util.Arrays;

//渠道枚举值
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@Getter
public enum ChannelType {

    PERSONAL(1,"个险业务部门"),
    SERVICE(7,"服务拓展部门");

    @EnumValue
    private int code;

    private String value;

    ChannelType(int code, String value) {
        this.value = value;
        this.code = code;
    }

    @JsonCreator
    public static ChannelType getItem(int code) {
        return Arrays.stream(ChannelType.values())
                .filter(i -> i.getCode() == code)
                .findAny().orElse(null);
    }
}
